package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Department;
import com.g8.pethospitallearnbackend.entity.DepartmentExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface DepartmentMapper {
    @SelectProvider(type=DepartmentSqlProvider.class, method="countByExample")
    long countByExample(DepartmentExample example);

    @DeleteProvider(type=DepartmentSqlProvider.class, method="deleteByExample")
    int deleteByExample(DepartmentExample example);

    @Delete({
        "delete from department",
        "where depart_id = #{departId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String departId);

    @Insert({
        "insert into department (depart_id, depart_name, ",
        "device_pic, staff_id, ",
        "depart_desc, depart_device)",
        "values (#{departId,jdbcType=VARCHAR}, #{departName,jdbcType=VARCHAR}, ",
        "#{devicePic,jdbcType=VARCHAR}, #{staffId,jdbcType=VARCHAR}, ",
        "#{departDesc,jdbcType=LONGVARCHAR}, #{departDevice,jdbcType=LONGVARCHAR})"
    })
    int insert(Department record);

    @InsertProvider(type=DepartmentSqlProvider.class, method="insertSelective")
    int insertSelective(Department record);

    @SelectProvider(type=DepartmentSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="depart_id", property="departId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="depart_name", property="departName", jdbcType=JdbcType.VARCHAR),
        @Result(column="device_pic", property="devicePic", jdbcType=JdbcType.VARCHAR),
        @Result(column="staff_id", property="staffId", jdbcType=JdbcType.VARCHAR),
        @Result(column="depart_desc", property="departDesc", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="depart_device", property="departDevice", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Department> selectByExampleWithBLOBs(DepartmentExample example);

    @SelectProvider(type=DepartmentSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="depart_id", property="departId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="depart_name", property="departName", jdbcType=JdbcType.VARCHAR),
        @Result(column="device_pic", property="devicePic", jdbcType=JdbcType.VARCHAR),
        @Result(column="staff_id", property="staffId", jdbcType=JdbcType.VARCHAR)
    })
    List<Department> selectByExample(DepartmentExample example);

    @Select({
        "select",
        "depart_id, depart_name, device_pic, staff_id, depart_desc, depart_device",
        "from department",
        "where depart_id = #{departId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="depart_id", property="departId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="depart_name", property="departName", jdbcType=JdbcType.VARCHAR),
        @Result(column="device_pic", property="devicePic", jdbcType=JdbcType.VARCHAR),
        @Result(column="staff_id", property="staffId", jdbcType=JdbcType.VARCHAR),
        @Result(column="depart_desc", property="departDesc", jdbcType=JdbcType.LONGVARCHAR),
        @Result(column="depart_device", property="departDevice", jdbcType=JdbcType.LONGVARCHAR)
    })
    Department selectByPrimaryKey(String departId);

    @UpdateProvider(type=DepartmentSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Department record, @Param("example") DepartmentExample example);

    @UpdateProvider(type=DepartmentSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Department record, @Param("example") DepartmentExample example);

    @UpdateProvider(type=DepartmentSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Department record, @Param("example") DepartmentExample example);

    @UpdateProvider(type=DepartmentSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Department record);

    @Update({
        "update department",
        "set depart_name = #{departName,jdbcType=VARCHAR},",
          "device_pic = #{devicePic,jdbcType=VARCHAR},",
          "staff_id = #{staffId,jdbcType=VARCHAR},",
          "depart_desc = #{departDesc,jdbcType=LONGVARCHAR},",
          "depart_device = #{departDevice,jdbcType=LONGVARCHAR}",
        "where depart_id = #{departId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(Department record);

    @Update({
        "update department",
        "set depart_name = #{departName,jdbcType=VARCHAR},",
          "device_pic = #{devicePic,jdbcType=VARCHAR},",
          "staff_id = #{staffId,jdbcType=VARCHAR}",
        "where depart_id = #{departId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Department record);
}